package com.cskaoyan.controller;

/**
 * @author pengyehua
 * @date 2020/12/6 21:20
 */

import com.cskaoyan.bean.*;
import com.cskaoyan.service.AdminOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 商场管理的订单模块
 */
@RestController
@RequestMapping("admin/order")
public class AdminOrderController {

    @Autowired
    AdminOrderService adminOrderService;

    /**
     * 查询订单
     * @param orderBO
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list(OrderBO orderBO){
        ListData<Order> orderListData = adminOrderService.queryOrder(orderBO);
        return BaseRespVo.ok(orderListData);
    }

    /**
     * 查询订单详情
     * @param id
     * @return
     */
    @RequestMapping("detail")
    public BaseRespVo detail(Integer id){
        OrderDetail orderDetail = adminOrderService.queryOrderDetail(id);
        return BaseRespVo.ok(orderDetail);
    }

    /**
     * 处理退款
     * @param map
     * @return
     */
    @PostMapping("refund")
    public BaseRespVo refund(@RequestBody Map map){

        adminOrderService.updateOrderStatus(map);
        return BaseRespVo.ok();
//        return new Result(621,"订单退款失败");
    }

    /**
     * 处理发货
     * @param map
     * @return
     */
    @PostMapping("ship")
    public BaseRespVo ship(@RequestBody Map map){
        adminOrderService.updateOrderShip(map);
        return BaseRespVo.ok();
    }

    @PostMapping("reply")
    public Result reply(@RequestBody Map map){
        return new Result(622,"订单商品已回复");
    }

}
